package com.ls.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ls.entity.ChinaArea;
import com.ls.mapper.ChinaAreaMapper;
import com.ls.service.IChinaAreaService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 区域表 服务实现类
 * </p>
 *
 * @author pengyu
 * @since 2025-08-26
 */
@Service
public class ChinaAreaServiceImpl extends ServiceImpl<ChinaAreaMapper, ChinaArea> implements IChinaAreaService {

    @Override
    public List<ChinaArea> getProvinces() {
        return list(new LambdaQueryWrapper<ChinaArea>()
                .eq(ChinaArea::getLevelType, 1)
                .orderByAsc(ChinaArea::getAreaId));
    }

    @Override
    public List<ChinaArea> getCitiesByProvinceId(String provinceId) {
        return list(new LambdaQueryWrapper<ChinaArea>()
                .eq(ChinaArea::getParentId, provinceId)
                .eq(ChinaArea::getLevelType, 2)
                .orderByAsc(ChinaArea::getAreaId));
    }

    @Override
    public List<ChinaArea> getDistrictsByCityId(String cityId) {
        return list(new LambdaQueryWrapper<ChinaArea>()
                .eq(ChinaArea::getParentId, cityId)
                .eq(ChinaArea::getLevelType, 3)
                .orderByAsc(ChinaArea::getAreaId));
    }
}